
//
//  YKStatusCell.m
//  youkan
//
//  Created by mac mini on 16/3/3.
//  Copyright © 2016年 Honsintech. All rights reserved.
//

#import "YKStatusCell.h"
#import "YKOrigninalView.h"
#import "YKRetweetView.h"
#import "YKStatusToolBar.h"
#import "YKStatusFrame.h"
#import "YKWBStatues.h"
@interface YKStatusCell ()
@property(nonatomic,weak) YKOrigninalView *originalView;
@property(nonatomic,weak) YKRetweetView *retweetView;
@property(nonatomic,weak) YKStatusToolBar *toolBarView;

@end

@implementation YKStatusCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//      添加所有子控件的方法
        [self setUpAllChildView];
        self.backgroundColor =[UIColor clearColor];
    }
    return self;
}
+(instancetype)cellWithTalbeView:(UITableView *)tableView{
    static NSString *ID =@"cell";
    id cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) { //!>  这种情况下tableView就不用注册Cell
        cell =[[self alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return cell;
}
//!>  初始化子控件：1.创建对象，2.添加到父控件，3.引用对象。
-(void)setUpAllChildView{
    YKOrigninalView *originalView =[[YKOrigninalView alloc]init];
    [self addSubview:originalView];
    _originalView = originalView;
    YKRetweetView *retweetView =[[YKRetweetView alloc]init];
    [self addSubview:retweetView];
    _retweetView =retweetView;
    YKStatusToolBar *toolBarView=[[YKStatusToolBar alloc]init];
    [self addSubview:toolBarView];
    _toolBarView =toolBarView;
}
-(void)setStatusF:(YKStatusFrame *)statusF{
    _statusF =statusF;
//      设置原创微博的frame
//    YKLog( @"1111%@",statusF.status.source);
    _originalView.frame =statusF.originalF;
    _originalView.statusF =statusF;
//    YKLog(@"%@",_originalView.statusF.status.source);

    if (statusF.status.retweeted_status) {
        // 设置原创微博frame
        _retweetView.frame = statusF.retweetF;
        _retweetView.statusF = statusF;
        _retweetView.hidden =NO;
    }else{
        _retweetView.hidden=YES;
    }
//    设置转发微博的frame
//    _retweetView.frame =statusF.retweetF;
//    _retweetView.statusF =statusF;
    //    设置工具条的frame
    _toolBarView.frame =statusF.toolBarF;
    _toolBarView.status =statusF.status;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
